package com.shadow.service.impl;

import com.shadow.dao.BaseDao;
import com.shadow.domain.User;
import com.shadow.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by qq65827 on 2015/1/8.
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private BaseDao baseDao;
    static String addUser = "insert into user(username,password,first_name,last_name,birthday,age) values(:userName,:passWord,:firstName,:lastName,:birthday,:age);";
    static String getUser = "select * from user where username = ? and password = ?";

    @Override
    public User getUser(String userName, String password) {
        User user = baseDao.getObject(getUser, User.class, new Object[]{userName,password});
        return user;
    }
    @Override
    public void addUser(User user) {
        baseDao.saveOrUpdateObject(addUser, user);
    }
}
